package com.anglireports.web.controller;

import com.anglireports.report.response.util.DateUtil;
import com.anglireports.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 学生报告
 * @author lvjilei
 * @ceateTime 2019/3/30.
 */
@Controller
public class ReportDataControler {


    private static final String MODEL = "/api/data";
    @Autowired
    private ReportService reportService;

    @RequestMapping(MODEL + "/student")
    @ResponseBody
    public String angliStudentPageData(String tokenid, String userid, String startdate, String enddate,
                                       String classid,
                                       String studentid){
        return reportService.getStudentPageData(DateUtil.strStrToiso(startdate, 0), DateUtil.strStrToiso(enddate, 1), classid, studentid);
    }


    @RequestMapping(MODEL + "/campus")
    @ResponseBody
    public String angliCampusPageData(String tokenid, String userid, String startdate, String enddate,
                                       String campusid){
        return reportService.getCampusPageData(DateUtil.strStrToiso(startdate, 0), DateUtil.strStrToiso(enddate, 1), campusid);
    }

    @RequestMapping(MODEL + "/class")
    @ResponseBody
    public String angliCoursePageData(String startdate, String enddate,
                                      String campusid,
                                     String classid){
        return reportService.getClassPageData(classid, DateUtil.strStrToiso(startdate, 0), DateUtil.strStrToiso(enddate, 1), null);
    }

}
